<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Shops_mdl extends CI_Model {

	const TABLE = 'shops';

	public function select(){
        return $this->db->get(self::TABLE)->result_array();
    }

    public function get_one(){
        return $this->db->get(self::TABLE)->row_array();
    }

    //统计
    public function get_count(){
        return $this->db->count_all_results(self::TABLE);
    }

    //添加
    public function create($data){
        return $this->db->insert(self::TABLE,$data);
    }
    //修改
    public function update($data){
        return $this->db->update(self::TABLE,$data);
    }
    //删除
    public function delete(){
        return $this->update($data);
    }

    //组装商铺
    public function assembly($list){
        $this->load->model('users_mdl');
        foreach($list as $k => $v){
            if(!empty($v['uid'])){
                $this->db->where('user_id',$v['uid']);
                $list[$k]['users'] = $this->users_mdl->get_one();
            }
        } 

        return $list;
    }

}

/* End of file Shops_mdl.php */
/* Location: ./application/models/Shops_mdl.php */